package com.ccxe.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//300成分工具
public class CS300Util {

	private static final Log LOG = LogFactory.getLog(CS300Util.class);
	public static final String SYSTEM_PATH = System.getProperty("user.dir");
	private static final File CS300_DATA = new File(SYSTEM_PATH
			+ File.separator + "conf/CS300");

	public static int[] getCS300() {
		LOG.info("CS300_DATA_PATH :  "+ CS300_DATA);
		Reader read = null;
		BufferedReader br = null;
		int[] cs300;
		try {
			read = new FileReader(CS300_DATA);
			br = new BufferedReader(read);
			List<Integer> list = new ArrayList<Integer>();
			while (br.ready()) {
				list.add(Integer.parseInt(br.readLine()));
			}
			cs300 = new int[list.size()];
			for (int i = 0; i < list.size(); i++) {
				cs300[i] = list.get(i);
			}
			return cs300;
		} catch (ArrayIndexOutOfBoundsException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void main(String[] args) {
		int[] a = getCS300();
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]+",");
		}
	}
}
